<script lang="ts" setup>
import { useRoute } from 'vue-router';
const route = useRoute();
setTimeout(() => {
  console.log(route.meta.keepAlive, '组件缓存');

}, 1000)

</script>

<template>
  <router-view v-slot="{ Component, route }" v-if="route.meta.keepAlive">
    <keep-alive>
      <component :is="Component" :key="route.fullPath" />
    </keep-alive>
  </router-view>
  <router-view v-else />

</template>

<style lang="scss" scoped></style>
